/**
 * Message.h - The official Lithne library.
 *
 * Copyright (c) 2011-2012
 * Serge Offermans, Remco Magielse
 * {s.a.m.offermans, r.magielse}@tue.nl
 * Intelligent Lighting Institute (ILI), TU/e.
 *
 * All rights reserved. LAST UPDATE: 01-04-2012
**/

#ifndef Message_h
#define Message_h

#include "Node.h"
#include "XBee.h"
#include "LithneDefinitions.h"

#ifndef MAX_ARGS
	#define MAX_ARGS 20
#endif

class Message
{
  public:
	Message();
	
	~Message();
	
	void clearArguments();

	void setRecipient64( XBeeAddress64 _addr64 );
	void setRecipient16( uint16_t _addr16 );
	void setFunction( 	 uint16_t _func );
	void setSender64( 	 XBeeAddress64 _addr64 );

	void setSender16( 	 uint16_t _addr16 );

	void setSender( 	 uint16_t _addr16, XBeeAddress64 _addr64 );
	void setScope( 		 uint16_t _scope );
	
	bool addArgument( uint16_t _arg );

//	boolean addArg( uint32_t* arg); Discuss with Elco how to implement this

	
	uint8_t  getNumberOfArguments();
	
	uint16_t getArgument( uint8_t _position );
	uint16_t getFunction( );
	uint16_t getSender16();
	uint16_t getRecipient16();
	uint16_t getScope();
	
	XBeeAddress64 getSender64( );
	XBeeAddress64 getRecipient64( );

  private:
/** Contains the number of arguments in the message **/
	uint8_t 		numArgs;
/** Contains the function identifier of the message (up to 255). You can come up with your own function table. **/
	uint16_t 		function;
	uint16_t 		args[MAX_ARGS];
/** Contains the 16 bit address of the Sender **/
	uint16_t		sender16;
/** Contains the 16 bit address of the Recipient **/
	uint16_t		recipient16;
/** Contains a 16-bit hash of the message scope/group.
This hash is used to determine for who the message is intended
Use setScope(String Scope) to determine who you want to send a message to.
Use hasScope(int scopeHash) to check if the message is intended for us. 
 **/
	uint16_t		scope;				
/** Contains the 64 bit address of the Sender **/ 
	XBeeAddress64	sender64;			
/** Contains the 64 bit address of the Recipient **/ 
	XBeeAddress64	recipient64;		
};

#endif

